--[[ 编码: JX-108-14 名称: 巨星任务-TOPVIEW-OUT-点执行出库 作者:HAN 日期:2025-1-29 级别:项目 函数: ClickRun 功能: -- 根据选中的任务 创建‘巨星出库’作业 更改记录: --]] jx_base= require( "jx_base" ) function ClickRun ( strLuaDEID ) local nRet, strRetInfo local strUserLogin, strUserName nRet, strUserLogin, strUserName = mobox.getCurUserInfo( strLuaDEID ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前操作人员信息失败! "..strUserLogin ) end -- 获取TOPVIEW的输入信息 nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "S_STATION_NO" ) lua.Debug( strLuaDEID, debug.getinfo(1), "点击出库-->", strRetInfo ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end local obj_attrs = json.decode( strRetInfo ) local station = lua.Get_StrAttrValue( obj_attrs[1].value ) if ( station == '') then mobox.setInfo( strLuaDEID, "输入参数不完整,无法执行出库作业!") return end -- 创建【巨星入库】作业 -- 获取站点货位,站点货位定义在常量中 local loc_code = jx_base.Get_Station_Loc( strLuaDEID, station ) local end_loc nRet, end_loc = wms_wh.GetLocInfo( loc_code ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), '获取货位信息失败! '..end_loc ) end -- 获取Grid中选中的【巨星任务】 local objs, obj_attrs nRet, objs = m3.GetSysDataJson( strLuaDEID ) if ( nRet ~=0 ) then lua.Error( strLuaDEID, debug.getinfo(1), objs ) end if ( objs == '') then mobox.setInfo( strLuaDEID, "请先选中一些需要执行的出库单!") return end local n local strUpdateSql, strCondition local start_loc local operation for n = 1, #objs do obj_attrs = m3.KeyValueAttrsToObjAttr( objs[n].attrs ) loc_code = wms_wh.GetLocCodeByCNTR( strLuaDEID, obj_attrs.S_CNTR_CODE ) if ( loc_code == '' ) then -- 4 表示任务执行失败 strUpdateSql = "N_B_STATE = 4, S_RUN_ERR = '料箱没有绑定货位!'" strCondition = "S_SOURNO = '"..obj_attrs.S_SOURNO.."'" nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "JX_Task", strCondition, strUpdateSql ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "更新【巨星任务】信息失败!"..strRetInfo ) end goto continue end nRet, start_loc = wms_wh.GetLocInfo( loc_code ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), '获取货位信息失败! '..start_loc ) end operation = m3.AllocObject(strLuaDEID,"Operation") operation.start_wh_code = start_loc.wh_code operation.start_area_code = start_loc.area_code operation.start_loc_code = start_loc.code operation.end_wh_code = end_loc.wh_code operation.end_area_code = end_loc.area_code operation.end_loc_code = end_loc.code operation.cntr_code = obj_attrs.S_CNTR_CODE operation.op_type = wms_base.Get_nConst(strLuaDEID, "作业类型-出库") operation.op_def_name = "巨星出库" operation.bs_type = "巨星任务" operation.bs_no = obj_attrs.S_SOURNO nRet, operation = m3.CreateDataObj( strLuaDEID, operation ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), '创建【作业】失败!'..operation ) end -- N_B_STATE = 1 任务执行 strUpdateSql = "N_B_STATE = 1, S_OP_CODE = '"..operation.code.."'" strCondition = "S_SOURNO = '"..obj_attrs.S_SOURNO.."'" nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "JX_Task", strCondition, strUpdateSql ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "更新【巨星任务】信息失败!"..strRetInfo ) end ::continue:: end local action = { { action_type = "refresh", value = "" } } mobox.setInfo( strLuaDEID, "系统已经成功创建巨星出库作业!") nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str(action) ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo ) end end